<!-- 配镜发料 -->
<template>
  <div class="mod-config">
    <el-tabs type="border-card" @tab-click="tabChange" v-model="tabValue">
      <el-tab-pane label="配镜发料" name="tab1">
        <el-button-group style="margin-bottom: 10px;">
          <el-button type="primary" icon="el-icon-search" @click="searchHandle">查找</el-button>
          <el-button type="primary" icon="el-icon-delete" @click="searchReset">清空</el-button>
          <el-button type="primary" style="margin-left: 10px;" @click="openDialogSend" :loading="isBatch">批量发料</el-button>
        </el-button-group>
        <el-form inline label-width="100px" @keyup.enter.native="searchHandle">
          <el-form-item label="配镜单号">
            <el-input v-model="dataForm.billId" placeholder="请输入配镜单号"></el-input>
          </el-form-item>
          <el-form-item label="配镜日期">
            <el-row>
              <el-col :span="11">
                <el-date-picker v-model="dataForm.createTimeStart" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
              </el-col>
              <el-col class="line" :span="2" style="text-align: center;">-</el-col>
              <el-col :span="11">
                <el-date-picker v-model="dataForm.createTimeEnd" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
              </el-col>
            </el-row>
          </el-form-item>
          <el-form-item label="顾客姓名">
            <el-input v-model="dataForm.customerName" placeholder="请输入顾客姓名"></el-input>
          </el-form-item>
          <el-form-item label="配镜类型">
            <el-select v-model="dataForm.saleType">
              <el-option value="4" label="镜架成品"></el-option>
              <el-option value="2" label="镜架订做"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="制造商">
            <el-input v-model="dataForm.supplyName">
              <el-button slot="append" @click="openSupplyDialog">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="商品品种">
            <el-input v-model="dataForm.brandName" placeholder="请选择">
              <el-button slot="append" @click="chooseBrand">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="销售门店">
            <el-select v-model="dataForm.deptId" placeholder="请选择销售门店" :disabled="userInfo.lessDeptId !=1">
              <el-option v-for="item in saleDeptOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="加急状态">
            <el-select v-model="dataForm.urgentStatus" placeholder="请选择加急状态">
              <el-option value="1" label="正常"></el-option>
              <el-option value="2" label="加急"></el-option>
            </el-select>
          </el-form-item>
        </el-form>

        <div class="avue-crud">
          <el-table :data="firstList" border v-loading="dataListLoading" :max-height="tableHeight1" @selection-change="selectionChangeHandle">
            <el-table-column type="selection" width="45"></el-table-column>
            <el-table-column prop="billId" label="配镜单号" width="170">
              <template slot-scope="scope">
                <el-button type="text" @click="checkDetailByOrder(scope.row.billId)">{{scope.row.billId}}</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="customerName" label="顾客姓名" width="120"></el-table-column>
            <el-table-column prop="saleType" label="配镜类型" width="80">
              <template slot-scope="scope">
                <!-- 1-隐形订做,2-框镜订做,3-隐形成品,4-框镜成品,5-辅料-->
                {{getSaleType(scope.row.saleType)}}
              </template>
            </el-table-column>
            <el-table-column prop="deptName" label="销售门店" width="140"></el-table-column>
            <el-table-column prop="createTime" label="配镜时间" width="150"></el-table-column>
            <el-table-column prop="takeMirroTime" label="取镜时间" width="150"></el-table-column>
            <el-table-column prop="urgentStatus" label="加急状态" width="70">
              <template slot-scope="scope">
                <!--加急状态(1-正常,2-加急)-->
                <span v-if="scope.row.urgentStatus == '1'">正常</span>
                <span v-if="scope.row.urgentStatus == '2'">加急</span>
              </template>
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button v-if="permissions.eims_sale_glasssend" type="text" icon="el-icon-edit" style="margin-right: 10px;"
                  @click="glassSendHandle(scope.row.id)">发料</el-button>
                <a :href="printUrl" target="_blank">
                  <el-button type="text" icon="el-icon-printer" @click="getPrintParams(scope.row.id)">打印</el-button>
                </a>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100, 200]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next">
          </el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="配镜发料(自动刷新)" name="tab3">
        <el-row style="margin: 0 0 5px 0;text-align: center;background-color: #DCDFE6;">
          <el-input v-model="countdown" style="width: 190px;">
            <template slot="prepend">还有</template>
            <template slot="append">秒刷新</template>
          </el-input>
          <!-- 距离自动刷新还有<input type="text" v-model="countdown">秒 -->
        </el-row>
        <div class="avue-crud">
          <el-table :data="thirdList" border v-loading="dataListLoading" :max-height="tableHeight3" @selection-change="selectionChangeHandle">
            <el-table-column prop="billId" label="配镜单号" width="170">
              <template slot-scope="scope">
                <el-button type="text" @click="checkDetailByOrder(scope.row.billId)">{{scope.row.billId}}</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="customerName" label="顾客姓名" width="120"></el-table-column>
            <el-table-column prop="saleType" label="配镜类型" width="80">
              <template slot-scope="scope">
                <!-- 1-隐形订做,2-框镜订做,3-隐形成品,4-框镜成品,5-辅料-->
                {{getSaleType(scope.row.saleType)}}
              </template>
            </el-table-column>
            <el-table-column prop="deptName" label="销售门店" width="140"></el-table-column>
            <el-table-column prop="createTime" label="配镜时间" width="150"></el-table-column>
            <el-table-column prop="takeMirroTime" label="取镜时间" width="150"></el-table-column>
            <el-table-column prop="urgentStatus" label="加急状态" width="70">
              <template slot-scope="scope">
                <!--加急状态(1-正常,2-加急)-->
                <span v-if="scope.row.urgentStatus == '1'">正常</span>
                <span v-if="scope.row.urgentStatus == '2'">加急</span>
              </template>
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button v-if="permissions.eims_sale_glasssend" type="text" icon="el-icon-edit" style="margin-right: 10px;"
                  @click="glassSendHandle(scope.row.id)">发料</el-button>
                <a :href="printUrl" target="_blank">
                  <el-button type="text" icon="el-icon-printer" @click="getPrintParams(scope.row.id)">打印</el-button>
                </a>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100, 200]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next">
          </el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="已发料配镜单" name="tab2">
        <el-button-group style="margin-bottom: 10px;">
          <el-button type="primary" icon="el-icon-search" @click="searchHandle">查找</el-button>
          <el-button type="primary" icon="el-icon-delete" @click="searchReset">清空</el-button>
        </el-button-group>
        <el-form inline label-width="100px" @keyup.enter.native="searchHandle">
          <el-form-item label="配镜单号">
            <el-input v-model="dataForm.billId" placeholder="请输入配镜单号"></el-input>
          </el-form-item>
          <el-form-item label="配镜日期">
            <el-row>
              <el-col :span="11">
                <el-date-picker v-model="dataForm.createTimeStart" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
              </el-col>
              <el-col class="line" :span="2" style="text-align: center;">-</el-col>
              <el-col :span="11">
                <el-date-picker v-model="dataForm.createTimeEnd" style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
              </el-col>
            </el-row>
          </el-form-item>
          <el-form-item label="顾客姓名">
            <el-input v-model="dataForm.customerName" placeholder="请输入顾客姓名"></el-input>
          </el-form-item>
          <el-form-item label="配镜类型">
            <el-select v-model="dataForm.saleType">
              <el-option value="4" label="镜架成品"></el-option>
              <el-option value="2" label="镜架订做"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="销售门店">
            <el-select v-model="dataForm.deptId" placeholder="请选择销售门店">
              <el-option v-for="item in saleDeptOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="加急状态">
            <el-select v-model="dataForm.urgentStatus" placeholder="请选择加急状态">
              <el-option value="1" label="正常"></el-option>
              <el-option value="2" label="加急"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="制造商">
            <el-input v-model="dataForm.supplyName">
              <el-button slot="append" @click="openSupplyDialog">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="商品品种">
            <el-input v-model="dataForm.brandName" placeholder="请选择">
              <el-button slot="append" @click="chooseBrand">选择</el-button>
            </el-input>
          </el-form-item>
        </el-form>
        <div class="avue-crud">
          <el-table :data="secondList" border v-loading="dataListLoading" :max-height="tableHeight2">
            <el-table-column prop="billId" label="配镜单号" width="170">
              <template slot-scope="scope">
                <el-button type="text" @click="checkDetailByOrder(scope.row.billId)">{{scope.row.billId}}</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="customerName" label="顾客姓名" width="120"></el-table-column>
            <el-table-column prop="saleType" label="配镜类型" width="80">
              <template slot-scope="scope">
                <!-- 1-隐形订做,2-框镜订做,3-隐形成品,4-框镜成品,5-辅料-->
                {{getSaleType(scope.row.saleType)}}
              </template>
            </el-table-column>
            <el-table-column prop="deptName" label="销售门店" width="140"></el-table-column>
            <el-table-column prop="createTime" label="配镜时间" width="150"></el-table-column>
            <el-table-column prop="takeMirroTime" label="取镜时间" width="150"></el-table-column>
            <el-table-column prop="sendMaterialUserName" label="发料人" width="80"></el-table-column>
            <el-table-column prop="sendMaterialTime" label="发料时间" width="150"></el-table-column>

            <el-table-column label="操作" width="180" fixed="right">
              <template slot-scope="scope">
                <el-button v-if="permissions.eims_delivery_edit" type="text" icon="el-icon-edit" style="margin-right: 10px;"
                  @click="getInfoHandle(scope.row.id)">查看</el-button>
                <el-button type="text" icon="el-icon-edit" style="margin-right: 10px;" :disabled="scope.row.saleStatus != '6'"
                  @click="cancelTheOrder(scope.row.billId)">删除</el-button>
                <a :href="printUrl" target="_blank">
                  <el-button type="text" icon="el-icon-printer" @click="getPrintParams(scope.row.id)">打印</el-button>
                </a>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100, 200]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next">
          </el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>
    <el-dialog title="隐形配送并调拨到门店" :visible.sync="dialogShow" width="30%">
      <el-form ref="dataForm" :model="dataForm" :rules="dataRule">
        <el-form-item label="配送人员">
          <el-select v-model="dataForm.userId" placeholder="请选择" @change="userNameChange($event)">
            <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogShow = false">取 消</el-button>
        <el-button type="primary" @click="shopSendOrder" :loading="ischeck" v-prevent-re-click>确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="批量发料" :visible.sync="changeWorkDept" width="30%">
      <el-button class="miui-dialog-close-btn" @click="changeWorkDept = false">关闭页面</el-button>
      <el-form ref="dataForm" :model="dataForm" :rules="dataRule">
        <el-form-item label="加工部门">
          <el-select v-model="dataForm.workDeptId" filterable default-first-option>
            <el-option v-for="item in workDeptOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="changeWorkDept = false">取 消</el-button>
        <el-button type="primary" @click="batchSend" :loading="ischeck" v-prevent-re-click>确 定</el-button>
      </span>
    </el-dialog>
    <!-- 弹窗, 配镜单发料详情 -->
    <send-detail v-if="sendDetailVisible" ref="sendDetail" @refreshDataList="getDataList"></send-detail>
    <!-- 弹窗， 查看详情 -->
    <detail-dialog v-if="detailDialogVisible" ref="detailDialog"></detail-dialog>
    <!-- 弹窗，制造商选择 -->
    <search-supply v-if="supplyVisible" ref="supplyDialog" @refreshData="getSupplyData"></search-supply>
    <!-- 弹窗，查找商品品种 -->
    <search-brand v-if="brandVisible" ref="brandSearch" @refreshData="updateBrandForm"></search-brand>
    <!-- 配镜单详情 -->
    <order-info v-if="infoVisible" ref="infoDialog"></order-info>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'
  import { filterParams } from '@/util/tools'
  import { remote } from '@/api/admin/dict'
  import { getUserListNoRole } from '@/api/admin/user'
  import { getNeedDeliveryDeptList } from '@/api/eims/optician/delivery'
  import { batchUpdateSendGlassSale } from '@/api/eims/optician/glassSend.js'
  import { getDeptInfoByDeptTypes } from '@/api/admin/dept'
  import {
    getDeptInfoByDeptType,
    getDeptListByUnitId
  } from "@/api/admin/dept"
  import {
    getGlassesVOPage,
    getSentGlassesVOPage,
    updateSendGlassSale,
    cancelTheOrderByBillId
  } from '@/api/eims/optician/glassSend'

  import SendDetail from './sendDetail'
  import DetailDialog from '../glassesinfo/detail'
  import SearchSupply from './SearchSupply'
  import SearchBrand from './SearchBrand'
  import OrderInfo from '@/views/eims/optician/glassesinfo/detail'

  let params = '/saleGlassPrint.cpt&saleId='

  export default {
    data() {
      return {
        ischeck: false,
				isBatch: false,
        dialogShow: false,
        changeWorkDept: false,
        supplyVisible: false,
        brandVisible: false,
        tabValue: 'tab1',
        printUrl: '',
        countdown: 30,
        dataForm: {
          userId: '',
          saleIdList: [],
          deliveryType: "",
          deptId: '',
          userName: '',
          deptName: '',
          billId: '',
          workDeptId: '',
        },
        workDeptOptions: [],
        saleTypeData: [],
        firstList: [],
        secondList: [],
        thirdList: [],
        pageIndex: 1,
        pageSize: 200,
        totalPage: 0,
        dataListLoading: false,
        selectionList: [],
        userOptions: [],
        DeliveryDeptListOptions: [],
        detailDialogVisible: false, // 查看信息
        sendDetailVisible: false, // 点击配镜发料弹窗
        infoVisible: false,
        saleDeptOptions: [],
        dataRule: {
          userId: [{
            required: true,
            message: '配送人不能为空'
          }]
        }
      }
    },
    components: {
      DetailDialog,
      SendDetail,
      SearchSupply,
      SearchBrand,
      OrderInfo
    },
    created() {
      this.getDataList()
      this.getDeptList()
      remote('sale_type').then(result => {
        this.saleTypeData = result.data.data
      })
      if (this.userInfo.deptType != 3) {
        getDeptListByUnitId(this.userInfo.unitId).then(response => {
          if(response.data.code == '0'){
            this.$set(this.dataForm, 'deptId', response.data.data[0].id)
          }else{
            this.$message.error(response.data.msg)
          }
        })
      }
    },
    computed: {
      ...mapGetters(['permissions', 'userInfo', 'bizData']),
      tableHeight1: function(){
        return window.innerHeight - 260
      },
      tableHeight2: function(){
        return window.innerHeight - 260
      },
      tableHeight3: function(){
        return window.innerHeight - 260
      },

    },
    methods: {
      //  查询数据
      searchHandle() {
        this.pageIndex = 1
        this.getDataList()
      },
      tabChange(data) {
        clearInterval(this.setIn)
        for (let key in this.dataForm) {
          this.dataForm[key] = ''
        }
        this.firstList = []
        this.secondList = []
        this.thirdList = []
        this.getDataList()
        if (this.tabValue == 'tab3') {
          this.countdown = 30
          this.countDown()
        }
      },
      // 取镜部门change事件
      takeMirroDeptIdChange(val) {
        this.getDataList()
      },
      // 获取数据列表
      getDataList() {
        this.dataListLoading = true
        setTimeout(() => {
          // 配送类型(1-门店配送,2-隐形订做配送,3-加工配送)
          if (this.tabValue == 'tab1') {
            this.getUserList()
            let params1 = {
              current: this.pageIndex,
              size: this.pageSize
            }
            let params2 = filterParams(this.dataForm)
            // console.log(params2)
            getGlassesVOPage(Object.assign(params1, params2)).then(response => {
              if(response.data.code == '0'){
                this.firstList = response.data.data.records
                this.totalPage = response.data.data.total
              }else{
                this.$message.error(response.data.msg)
              }
              this.dataListLoading = false
            })
          } else if (this.tabValue == 'tab2') {
            let params1 = {
              current: this.pageIndex,
              size: this.pageSize,
              deliveryType: '2'
            }
            let params2 = filterParams(this.dataForm)
            getSentGlassesVOPage(Object.assign(params1, params2)).then(response => {
              if(response.data.code == '0'){
                this.secondList = response.data.data.records
                this.totalPage = response.data.data.total
              }else{
                this.$message.error(response.data.msg)
              }
              this.dataListLoading = false
            })
          } else if (this.tabValue == 'tab3') {
            let params1 = {
              current: this.pageIndex,
              size: this.pageSize
            }
            let params2 = filterParams(this.dataForm)
            getGlassesVOPage(Object.assign(params1, params2)).then(response => {
              if(response.data.code == '0'){
                this.thirdList = response.data.data.records
                this.totalPage = response.data.data.total
              }else{
                this.$message.error(response.data.msg)
              }
              this.dataListLoading = false
            })
          }
        }, 3000)
      },
      // 每页数据条数变化事件
      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页改变事件
      currentChangeHandle(val) {
        this.pageIndex = val
        this.getDataList()
      },
      //   根据配镜单号查看配镜单详情
      checkDetailByOrder(order) {
        this.infoVisible = true;
        this.$nextTick(() => {
          this.$refs.infoDialog.init('', order, '配镜单详情');
        });
      },
      // 查看
      getInfoHandle(id) {
        this.detailDialogVisible = true
        this.$nextTick(() => {
          this.$refs.detailDialog.init(id, '', '库存详细')
        })
      },
      // 发料
      glassSendHandle(id) {
        this.sendDetailVisible = true
        this.$nextTick(() => {
          this.$refs.sendDetail.init(id)
        })
      },
      //   获取打印的参数
      getPrintParams(id) {
        this.printUrl = this.bizData.printUrl + params + id
      },
      //获取配镜类型枚举
      getSaleType: function(value) {
        let obj = {};
        obj = this.saleTypeData.find((item) => {
          return item.value == value;
        });
        return obj.label;
      },
      // 搜索清空
      searchReset() {
        this.dataForm = {};
      },
      handleSearchShow() {
        this.searchShow = !this.searchShow;
      },
      // 多选表格change事件
      selectionChangeHandle(val) {
        this.selectionList = val
      },

      // 获取员工用户列表
      getUserList(id) {
        getUserListNoRole().then(response => {
          if(response.data.code == '0'){
            let resultData = response.data.data
            let userList = []
            resultData.forEach(item => {
              let userObj = {
                value: item.id,
                label: item.username
              }
              userList.push(userObj)
            })
            this.userOptions = userList
          }else{
            this.$message.error(response.data.msg)
          }
        })
      },
      userNameChange($event) {
        this.userOptions.forEach(item => {
          if (item.value == $event) {
            this.dataForm.userName = item.label
          }
        })
      },
      //弹框
      shopSend() {
        if (this.selectionList.length) {
          this.dialogShow = true
        } else {
          this.$message.warning('请选择配镜单')
        }
      },
      //点击门店配送接口
      shopSendOrder() {
        this.dataForm.saleIdList = [];
        let ids = []
        this.selectionList.forEach(item => {
          ids.push(item.saleId)
        })
        this.dataForm.saleIdList = ids;
        this.ischeck = true
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            updateSendGlassSale(this.dataForm).then(response => {
              if(response.data.code == '0'){
                this.$message.success("配送成功")
                this.dialogShow = false
                this.getDataList()
              }else{
                this.$message.error(response.data.msg)
              }
              this.ischeck = false
            }).catch(() => {
              this.ischeck = false
            })
          } else {
            this.ischeck = false
          }
        })
      },
      // 获取取镜门店列表
      getTakeMirroDeptList() {
        getNeedDeliveryDeptList({
          deliveryType: '2'
        }).then(result => {
          let resultData = result.data.data
          let list = []
          resultData.forEach(item => {
            list.push({
              value: item.id,
              label: item.name
            })
          })
          this.DeliveryDeptListOptions = list
        })
      },
      //   打开制造商选择弹窗
      openSupplyDialog() {
        this.supplyVisible = true
        this.$nextTick(() => {
          if (this.tabValue == 'tab1') {
            this.$refs.supplyDialog.init({
              ctgId: 3
            })
          } else {
            this.$refs.supplyDialog.init({
              ctgId: ''
            })
          }

        })
      },
      //   获取制造商信息
      getSupplyData(data) {
        this.$set(this.dataForm, 'supplyName', data.name)
        this.$set(this.dataForm, 'supplyId', data.id)
      },
      //打开
      chooseBrand() {
        this.brandVisible = true;
        if (!this.dataForm.supplyId) {
          this.$message.warning("请选择制造商")
          return
        }
        this.$nextTick(() => {
          if (this.tabValue == 'tab1') {
            this.dataForm.ctgId = 3
          }
          this.$refs.brandSearch.init(this.dataForm)
        })
      },
      updateBrandForm(data) {
        this.$set(this.dataForm, 'brandName', data.name)
        this.$set(this.dataForm, 'brandId', data.id)
      },
      //获取销售部门列表
      getDeptList() {
        getDeptInfoByDeptType(1).then(response => {
          this.saleDeptOptions = response.data.data;
        });
      },
      //  倒计时，定时刷新
      countDown() {
        if (this.tabValue == 'tab3') {
          if (this.countdown > 0) {
            this.countdown -= 1
            this.setIn = setTimeout(() => {
              this.countDown()
            }, 1000)
          } else {
            this.getDataList()
            setTimeout(() => {
              this.countdown = 30
              this.countDown()
            }, 1000)
          }
        }
      },
      //打开发料选择加工部门弹窗
      openDialogSend() {
        this.isBatch = true
        this.dataForm.workDeptId = ''
        if (this.selectionList.length) {
          this.changeWorkDept = true
        } else {
          this.$message.warning('请选择发料订单')
        }
        this.getWorkDeptList()
      },
      //批量发料
      batchSend() {
        if (!this.dataForm.workDeptId) {
          this.isBatch = false
          this.$message.warning("请选择发料接收的加工部门")
          return false
        }
        let ids = []
        this.selectionList.forEach((item, index) => {
          ids.push(item.id)
        })
        this.dataForm.ids = ids;
        this.ischeck = true
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            batchUpdateSendGlassSale(this.dataForm).then(response => {
              if(response.data.code == '0'){
                this.$message.success("批量发料成功")
                this.changeWorkDept = false
                this.getDataList()
              }else{
                this.$message.error(response.data.msg)
              }
              this.ischeck = false
              this.isBatch = false
            }).catch(() => {
              this.ischeck = false
              this.isBatch = false
            })
          } else {
            this.ischeck = false
            this.isBatch = false
          }
        })
      },
      //获取加工部门列表
      getWorkDeptList() {
        var data = {
          deptTypes: [2]
        }
        getDeptInfoByDeptTypes(data).then(response => {
          if(response.data.code == '0'){
            this.workDeptOptions = response.data.data
          }else{
            this.$message.error(response.data.msg)
          }
        })
      },
      cancelTheOrder(billId) {
        this.$confirm('是否确认删除销售单号为' + billId, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          })
          .then(function() {
            return cancelTheOrderByBillId(billId)
          })
          .then(response => {
            if(response.data.code == '0'){
              this.$message.success('删除成功')
              this.getDataList()
            }else{
              this.$message.error(response.data.msg)
            }
          })
      }
    }
  }
</script>
